<?php
/*************************************************************************************
 *
 *	FileName: /edp/lib/functions/classloader.php
 *	Desc    : This file is to load all the classes only on demand and once.
 *	Author  : Seal
 *	Date    : 2009-10-5
 *
 *************************************************************************************/

	function GetDB()
	{
		return GetClass( 'DB' );
	}
	
	function GetGiftCouponDAO()
	{
		return GetClass( 'GiftCouponDAO', MODEL_DIR );
	}
	
	function GetLetterDAO()
	{
		return GetClass( 'LetterDAO', MODEL_DIR );
	}
	
	function GetBreadcrumb()
	{
		return GetClass( 'Breadcrumb' );
	}
	
	function GetEventDispatcher()
	{
		return GetClass( 'EventDispatcher' );
	}
	
	function GetUserDAO()
	{
		return GetClass( 'UserDAO', MODEL_DIR );	
	}
	
	function GetShopDAO()
	{
		return GetClass( 'ShopDAO', MODEL_DIR );
	}
	
	function GetProductDAO()
	{
		return GetClass( 'ProductDAO', MODEL_DIR );
	}
	
	function GetCatgoryDAO()
	{
		return GetClass('CategoryDAO', MODEL_DIR);
	}
	
	function GetShopCategoryDAO()
	{
		return GetClass('ShopCategoryDAO', MODEL_DIR);
	}
	
	function GetProductCategoryDAO()
	{
		return GetClass('ProductCategoryDAO', MODEL_DIR);
	}
	
	function GetCityDAO()
	{
		return GetClass('CityDAO', MODEL_DIR);
	}
	
	function GetReviewDAO()
	{
		return GetClass('ReviewDAO', MODEL_DIR);
	}
	
	function GetShopPaymethodDAO()
	{
		return GetClass('ShopPaymethodDAO', MODEL_DIR);
	}
	
	function GetShopFeatureDAO()
	{
		return GetClass('ShopFeatureDAO', MODEL_DIR);
	}
	
	function GetListDAO()
	{
		return GetClass('ListDAO', MODEL_DIR);
	}
		
	function GetPlatformDAO()
	{
		return GetClass('PlatformDAO', MODEL_DIR);
	}
	
	function GetFriendDAO()
	{
		return GetClass('FriendDAO',MODEL_DIR);
	}
	
	function GetCollectionDAO()
	{
		return GetClass('CollectionDAO',MODEL_DIR);
	}
	
	function GetRecommendDAO()
	{
		return GetClass('RecommendDAO', MODEL_DIR);	
	}

	function GetEventDAO()
	{
		return GetClass('EventDAO', MODEL_DIR);	
	}
		
	function GetSearchDAO()
	{
		return GetClass('SearchDAO', MODEL_DIR);
	}
	
	function GetMessageStack()
	{
		return GetClass( 'MessageStack' );
	}
	
	function GetWebUI()
	{
		return GetClass( "WebUI" );
	}
	
	function GetEDPImage()
	{
		return GetClass( "EDPImage" );
	}
	
	function GetUploder()
	{
		return GetClass( "CUploader" );
	}
	
	function GetPhpMailer()
	{
		return GetClass( "phpmailer", LIB_DIR.'mail/');
	}
	
	function GetShopSearch()
	{
		return GetClass( "ShopSearch", LIB_DIR . 'search/', 'shopsearch' );
	}
	
	function GetProductSearch()
	{
		return GetClass( "ProductSearch", LIB_DIR . 'search/', 'productsearch' );
	}
	
	function GetReviewSearch()
	{
		return GetClass( "ReviewSearch", LIB_DIR . 'search/', 'reviewsearch' );
	}
	
	function GetListSearch()
	{
		return GetClass( "ListSearch", LIB_DIR . 'search/', 'listsearch' );
	}
	
	function GetUserSearch()
	{
		return GetClass( "UserSearch", LIB_DIR . 'search/', 'usersearch' );
	}
	
	function GetMailer()
	{
		return GetClass("Mailer");
	}

        function GetTaskManager(){
            require_once (LIB_DIR.'classes/httpsqs_client.php');
            return GetClass("TaskManager");
        }
	
	function GetDBLogger()
	{
		global $DBLogger;
		
		if( isset( $DBLogger ) )
			return $DBLogger;
	
		$logFileName = "error.log";

		$DBLogger = new EDPLogger( $logFileName, DB_LOG_FILE_PATH, DB_LOG_HISTORY_FILE_PATH, 1 );
		return $DBLogger;
	}
	
	function GetLogger()
	{
		global $Logger;
		
		if( isset( $Logger ) )
			return $Logger;
	
		$logFileName = "error.log";

		$Logger = new EDPLogger( $logFileName, LOG_FILE_PATH, LOG_HISTORY_FILE_PATH );
		return $Logger;
	}
	
	function GetCacheManager(){
		
		return GetClass("EDPCacheManager");
	}
	/**********************************************************
	 *
	 *	this function is to dynamically creatig the class.
	 *  For efficience, there is only one instance of every class
	 *  globally.
	 *	Seal Created On 2009-10-5
	 *
	 **********************************************************/
	
	function GetClass( $class, $path = CLASSES_DIR, $fileName = '' )
	{
		global $$class;
		
		if( isset($$class) )
			return $$class;
		else 
		{
			if( $fileName == '')
				require_once( $path . $class . ".php" );
			else
				require_once( $path . $fileName . ".php" );
			$$class = new $class();
			return $$class;
		}
	}



?>